#!/bin/sh

##add-by-ldg-20240711
. /lib/hclfuncs.sh

# DEBUG="logger -t lte_led_check -p debug "
ERROR="logger -t lte_led_check -p err "

INTERVAL=10

if [ X0 = X$(ls -d1 /sys/class/net/wwan* 2>/dev/null | wc -l) ]; then
  ${ERROR} "[${0##*/}] not found token wwan0"
  exit 1
fi

while true; do
  case $(timeout 2s ubus call led status | xargs | awk '/status: /{printf $3}') in
    1) {
      led_on lte2
    } ;;
    0) {
      led_off lte2
    } ;;
    *) {
      led_off lte2
    } ;;
  esac
  sleep ${INTERVAL}
done
